package zuoye.ershouche.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import zuoye.ershouche.entity.User;

import java.util.List;

@Mapper
public interface UserMapper {

    /**
     * 新建用户，根据手机号和密码
     */
    @Insert("insert into user (phone, password) values (#{phone}, #{password})")
    int insertUser(User user);

    /**
     * 查询用户，分页查询 pageHelper 插件
     */
    @Select("select * from user")
    List<User> selectUsersList(int pageNum, int pageSize);

    /**
     * 查询用户，全部查询
     */
    @Select("select * from user")
    List<User> selectUsersAll();

    /**
     * 删除用户
     */
    @Delete("delete from user where id = #{id}")
    int deleteUserById(Integer id);

    /**
     * 根据手机号密码查询用户
     */
    @Select("select * from user where id = #{id} and password = #{password}")
    int SelectUserByIDAndPassword();

}

